package com.shiwenping.reply;

import android.app.Activity;
import android.databinding.DataBindingUtil;
import android.databinding.ViewDataBinding;
import android.os.Bundle;
import android.support.annotation.LayoutRes;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;

import java.util.List;

/**
 * @author shiwenping
 * @date 17-11-6 下午1:32
 */

public abstract class BaseActivity<V extends ViewDataBinding> extends AppCompatActivity {
    protected V databinding;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        App.add(this);
        databinding = DataBindingUtil.setContentView(this, resLayout());
    }

    @Override
    protected void onDestroy() {
        App.remove(this);
        super.onDestroy();
    }

    /**
     * 获取当前Activity
     *
     * @return 当前Activity
     */
    protected Activity getActivity() {
        return this;
    }

    /**
     * 布局ID
     *
     * @return 布局id
     */
    @LayoutRes
    abstract int resLayout();
}
